const { Sequelize } = require('sequelize');
const config = require('../config');

const DATABASE = config.database;
const sequelize = new Sequelize(DATABASE.NAME,DATABASE.USERNAME,DATABASE.PASSWORD,{
  dialect:'mysql',
  host:DATABASE.HOST,
  port:DATABASE.PORT,
  logging:true,
  timezone:"+08:00",
  define:{
    timestamps:true,
    createdAt:"create_time",
    underscored:true//开启下划线命名方式，默认是驼峰命名。
  },
  timezone: '+08:00', //东八时区
  // 添加这个配置 
  dialectOptions: {
    dateStrings: true,
    typeCast: true
  }
});
sequelize.sync()
module.exports = sequelize;